package com.session04.homework;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class TestPoker {
    //在一个List集合中放入一副扑克牌，将其乱序（洗牌），然后分发给三个人（3个List），3个List分别按各自的规则整理自己的牌序列，然后进行展示。
    //第一个人按先花色（黑红樱方），后数字的方式排列（2AKQJ......），大小王最大；
    //第二个人按先数字，后花色的方式排列；
    //第三个人按摸到牌的顺序排列
    public static void main(String[] args) {
        List<Poker> lst = new ArrayList<>();
        String[] str = {"♠", "♥", "♣", "♦"};
        String[] str1 = {"大🃏", "小🃏", "2", "A", "K", "Q", "J", "10", "9", "8", "7", "6", "5", "4", "3"};
        lst.add(new Poker("", "大🃏"));
        lst.add(new Poker("", "小🃏"));

        for (int i = 0; i < str.length; i++) {
            for (int j = 2; j < str1.length; j++) {
                lst.add(new Poker(str[i], str1[j]));
            }
        }

        Collections.shuffle(lst);

        List<Poker> player1 = new ArrayList<>();
        List<Poker> player2 = new ArrayList<>();
        List<Poker> player3 = new ArrayList<>();

        for (int i = 0; i < 17; i++) {
            player1.add(lst.get(0));
            lst.remove(0);
            player2.add(lst.get(0));
            lst.remove(0);
            player3.add(lst.get(0));
            lst.remove(0);
        }

        Collections.sort(player1);
        Collections.sort(player2, new PokerComparator());

        System.out.print("第一个玩家：");
        for (Poker p : player1) {
            System.out.print(p + " ");
        }
        System.out.println();
        System.out.print("第二个玩家：");
        for (Poker p : player2) {
            System.out.print(p + " ");
        }
        System.out.println();
        System.out.print("第三个玩家：");
        for (Poker p : player3) {
            System.out.print(p + " ");
        }
        System.out.println();
        System.out.print("三张底牌：");
        for (Poker poker : lst) {
            System.out.print(poker + " ");
        }
    }
}
